package cn.stylefeng.guns.modular.service.impl;

import cn.stylefeng.guns.modular.entity.ScheduleFormItem;
import cn.stylefeng.guns.modular.entity.ScheduleFrameItem;
import cn.stylefeng.guns.modular.mapper.ScheduleFormItemMapper;
import cn.stylefeng.guns.modular.service.ScheduleFormItemService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ScheduleFormItemServiceImpl implements ScheduleFormItemService {
   @Resource
    private ScheduleFormItemMapper scheduleFormItemMapper;

    /**
     * 保存日程表项
     * @param scheduleFormItem
     * @return
     */
    public int saveScheduleFormItem(ScheduleFormItem scheduleFormItem){
        return scheduleFormItemMapper.saveScheduleFormItem(scheduleFormItem);
    }


    /**
     * 设置日程项的日程表id
     * @param sformId
     * @return
     */
    public int setFormId(int sformId){
       return  scheduleFormItemMapper.setFormId(sformId);
    }

    /**
     * 根据sformId删除日程项
     * @param sformId
     * @return
     */
    public int deleteBySformId(int sformId){
        return scheduleFormItemMapper.deleteBySformId(sformId);
    }


    /**
     * 根据日程表Id查找其日程项
     * @param sformId
     * @return
     */
    public List<ScheduleFormItem> selectSformItemBySformId(int sformId){
        return scheduleFormItemMapper.selectSformItemBySformId(sformId);
    }


    /**
     * 查看该日程表下哪个序号的所有日程项
     * @param sformId
     * @param itemSerial
     * @return
     */
    public List<ScheduleFormItem> selectSformItemBySformIdAndItemSerial(@Param("sformId") int sformId, @Param("itemSerial") int itemSerial){
        return scheduleFormItemMapper.selectSformItemBySformIdAndItemSerial(sformId,itemSerial);
    }


    /**
     * 显示今日的日程项信息
     * @param userId
     * @param todayDate
     * @return
     */
    public List<ScheduleFormItem> showTodaySfromItem(@Param("userId") long userId,@Param("todayDate") String todayDate){
        return scheduleFormItemMapper.showTodaySfromItem(userId,todayDate);
    }


    /**
     * 显示该日程表某框架项和某天的所有日程项
     * @param sformId
     * @param sframeItemSerail
     * @param sformItemDate
     * @return
     */
    public List<ScheduleFormItem> showCurrSformItem(@Param("sformId") int  sformId, @Param("sframeItemSerail") int sframeItemSerail, @Param("sformItemDate") String sformItemDate){
        return scheduleFormItemMapper.showCurrSformItem(sformId,sframeItemSerail,sformItemDate);
    }

    /**
     * 根据日程项id进行查询
     * @param sformItemId
     * @return
     */
    public ScheduleFormItem selectSformItemById(@Param("sformItemId") int sformItemId){
        return scheduleFormItemMapper.selectSformItemById(sformItemId);
    }

    /**
     * 保存修改日程项信息
     * @param scheduleFormItem
     * @return
     */
    public int updateSformItem(@Param("scheduleFormItem") ScheduleFormItem scheduleFormItem){
        return scheduleFormItemMapper.updateSformItem(scheduleFormItem);
    }


    /**
     * 根据日程项id进行删除
     * @param sformItemId
     * @return
     */
    public int deleteSformItemById(@Param("sformItemId") int sformItemId){
        return scheduleFormItemMapper.deleteSformItemById(sformItemId);
    }
}
